<!--  -->
<template>
<div>
    <mt-header title="订单详情">
  <router-link  to  slot="left">
    <mt-button icon="back" @click="$router.back(-1)"></mt-button>
  </router-link>
  <mt-button icon="more" slot="right"></mt-button>
    </mt-header>
    <div class="border">
            <div class="top">
                <p>订单状态:
                <span v-if="order.Status==1">未付款</span>
                <span v-else-if="order.Status==2">待付款</span>
                <span v-else-if="order.Status==3">已付款</span>
                <span v-else-if="order.Status==4">已发货</span>
                <span v-else-if="order.Status==5">交易成功</span>
                <span v-else-if="order.Status==6">交易关闭</span>
            </p>
                <p>订单编号:<span>{{ order.OrderNumber }}</span></p>
                <p>下单时间:<span>{{ order.CreateTime }}</span></p>
                <van-popup v-model="show" position="bottom" :style="{ height: '20%' }" >
                <p id="butt2" @click="setStatuu(order.oid)">支付宝支付</p>
                <p id="butt3" @click="setStatuu(order.oid)">微信支付</p>
            </van-popup>
                <p v-if="order.Status==2" class="butt1" @click="setStatu(order.oid)">去支付</p>
                <p v-if="order.Status==2" class="butt" @click="setStatus(order.oid)">取消订单</p>
                <p v-if="order.Status==3" class="butt" @click="setStatus(order.oid)">取消订单</p>
                
            </div>
            <div class="middle">
                <p>商品金额:<span>￥{{ order.Payment}}</span></p>
                <p>配送方式:<span>{{ order.Courier }}</span></p>
            </div>
            <div class="foot">
                <div class="order" v-for="item in data" :key="item.Ooid"  >
                    <div class="img">
                    <img :src="require(`../assets/img/product/${item.Img}`)" alt="">
                </div>
                <div class="text">
                    <p>{{item.title}}</p>
                    <p>全场包邮</p>
                    <div class="time">
                        <span>￥{{ item.price }}</span>
                        <span>x{{ item.Sum }}</span>
                    </div>
                </div>
               
            </div>
            </div>
    </div>
</div>
</template>

<script>
import { Dialog } from 'vant';
import { Toast } from 'vant';
export default {
data() {
return {
    oid:"",
    data:"",
    order:"",
    show:false
}
},
//生命周期 - 创建完成（访问当前this实例）
created() {

},
//生命周期 - 挂载完成（访问DOM元素）
mounted() {
    this.oid=this.$route.params.oid
    this.getdata()
},
methods:{
    getdata(){
        var url=`/GetOrderDetail?oid=${this.oid}`
        console.log(url)
        this.axios.get(url).then(res=>{
            console.log(res)
            this.data=res.data.results
            this.order=res.data.order[0]
            console.log(this.data)
            console.log(this.order)
        })
    },
    setStatu(a){
        this.show=true
        console.log(a)
    },
    setStatus(a){
        console.log(a)
        Dialog.confirm({
         message: '是否取消订单',
})
  .then(() => {
    // on confirm
    console.log("确定")
    var url=`/SetOrderDetail?oid=${this.oid}`
    this.axios.get(url).then(res=>{
            console.log(res)
            this.getdata()
        })

  })
  .catch(() => {
    // on cancel
  });
    },
    setStatuu(a){
        console.log(a)
        var url=`/SetOrderDetails?oid=${this.oid}`
    this.axios.get(url).then(res=>{
            console.log(res)
            this.show=false
            Toast.success('支付成功');
            this.getdata()
    })
}
}
}
</script>
<style scoped>
/* @import url(); 引入css类 */
.mint-header{
    color: black;
    background-color: white;
    font-size: 10px;
}
.top,.middle,.foot{
    padding-bottom: 20px;
    
}
.top,.middle{
    margin: 20px;
}
.top p,.middle p{
    font-size: 12px;
    color: rgb(153, 153, 153);
    margin: 10px 0;
}
.top p span,.middle p span{
    margin-left: 10px;
    font-size: 13px;
    color: black;
}
.top .butt{
    width: 100%;
    line-height: 40px;
    color: black;
    text-align: center;
    border: .02667rem solid #ebedf0;
}
.top .butt1{
    width: 100%;
    line-height: 40px;
    color: white;
    text-align: center;
    background-color: rgb(27, 174, 174);
    border: .02667rem solid #ebedf0;
}

#butt2,#butt3{
    margin-top: 15px;
    width: 80%;
    margin-left: 10%;
    line-height: 40px;
    color: white;
    text-align: center;
    background-color: aquamarine
}
#butt2{
    background-color: rgb(25, 137, 250);
}
#butt3{
    background-color: rgb(79, 172, 141);
}

.order{
    display: flex;
    font-size: 12px;
    height: 80px;
    /* border-top: 1px solid rgb(224, 224, 224); */
    /* border-bottom: 1px solid rgb(224, 224, 224);   */
}
.order .img{
    width:30%;
}
.order img{
    width: 100%;
    height: 100%;
}
.order .text{
    width: 70%;
    /* margin-top: 5px; */
}
.order .text p{
    margin-top: 3px;
}
.order .text .time{
    margin-top: 8px;
}
.order .text p:nth-child(2){
    /* margin-top: 10px; */
    color: rgb(100, 101, 102);
    /* color: aqua; */
}

.order .price{
    width: 25%;
    text-align: center;
}
.order .price p{
    margin-top: 10px;
    font-size: 15px;
    margin-left: 20px;
    /* align-items: center; */

} 
.order .price :nth-child(2){
    margin-top: 5px;
    font-size: 15px;
    margin-left: 50px;
    /* color: aqua; */
    /* align-items: center; */
} 
.time span:first-child{
    font-size: 12px;
    margin-left: 10px;
}
.time span:last-child{
    font-size: 12px;
    margin-left: 10px;
    float: right;
    margin-right: 30px;
}
</style>